
<?php
	
	include("verif_session.php");
	include("bdd_connection.php");
	
	include_once('config.php');   
	include_once('Connect_pdo.php');
	
	extract($_GET);
	extract($_POST);

	if(isset($ajout))
	{
	   mysql_query (" INSERT INTO tache VALUES('$id','$objectif','$designation','$datedebut')");
	   $message="Ajout effectué!";
	   $smarty->assign("message",$message);
  
       mysql_close();
	}


	if(isset($id))
	{
	   mysql_query (" UPDATE tache set nom='$nom', type='$type', description='$description' where idTache=$id");
	   $message="Modification effectueé avec succes!";
	   $smarty->assign("message",$message);
  
       mysql_close();
	}
	

	if(isset($id_sup))
	{
	   mysql_query (" DELETE FROM tache where idTache=$id_sup");
	   $message="Suppression effectueé avec succes!";
	   $smarty->assign("message",$message);
  
       mysql_close();
	}

$query = $con->prepare("select * from tache");
		if($query->execute()){
			$count = $query->rowCount();
			$query->setFetchMode(PDO::FETCH_OBJ);
			if($count > 0){
				while($line = $query->fetch()){
					$return[] = array(
								"ID"=> $line->idTache,
								"objectif"=> $line->objectif,
								"designation"=> $line->designation,
								"dateDebut"=> $line->dateDebut
								
								
								
								);
				}
				
				$smarty->assign("return", $return);
				$smarty->display("planning.html");
			
	}
	}
	?>




	
